﻿using EasyCore.UnitOfWork.Filters;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EasyCore.UnitOfWork
{
    /// <summary>
    /// 增加工作单元
    /// </summary>
    public static class ServiceCollectionExtensions
    {
        /// <summary>
        /// 增加工作单元
        /// </summary>
        /// <param name="services"></param>
        /// <returns></returns>
        public static IServiceCollection AddUnitOfWork(this IServiceCollection services)
        {
            //在执行方法上增加工作单元执行逻辑
            services.Configure<MvcOptions>(options =>
            {
                options.Filters.Add<UnitOfWorkFilter>();
            });
            return services;
        }
    }
}
